#ifndef _BOARD_H_
#define _BOARD_H_

#include "mem_info.h"
#include "app_config.h"
#include "mcu.h"

#define BSP_MCU_MODEL       POLSYS_MCU_STM32


#if defined(__CC_ARM) || defined(__CLANG_ARM)
extern int Image$$RW_IRAM1$$ZI$$Limit;
#define HEAP_BEGIN      ((void *)&Image$$RW_IRAM1$$ZI$$Limit)
#elif __ICCARM__
#pragma section="CSTACK"
#define HEAP_BEGIN      (__segment_end("CSTACK"))
#else
extern int __bss_end;
#define HEAP_BEGIN      ((void *)&__bss_end)
#endif
#define HEAP_END        ((void *)SRAM_END)



#if APP_DRIVE_SELECT == 1
#define RT_CONSOLE_DEVICE_NAME      "usart1"
int rt_hw_usart_init();
#define Board_InitConsoleDevice()   rt_hw_usart_init()

#define LED_PIN     GET_PIN(B, 5)
#define Led_On()		rt_pin_write(LED_PIN, PIN_HIGH)
#define Led_Off()		rt_pin_write(LED_PIN, PIN_LOW)
#define Led_Init()		rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT);
#define Led_IsOn()      rt_pin_read(LED_PIN)

#else
void Board_InitConsoleDevice();   
#define Led_Init()
STATIC_FORCE_IN_LINE void Led_On(){}
STATIC_FORCE_IN_LINE void Led_Off() {}    
STATIC_FORCE_IN_LINE bool Led_IsOn()  {return true;}  
#endif



#define Board_GetTickCycleValue()   SYSTICK_VALUE
#define Board_GetTickNowValue()     (u32)(SYSTICK_VALUE - SysTick->VAL)



void Error_Handler(void);

#endif
